<template>
  <div>

    <div>


    </div>

    <el-table
      :data="tableData"

      border
      show-summary      style="width: 100%; margin-top: 20px">

      <el-table-column
        prop="bankName"
        label="银行名称">
      </el-table-column>
      <el-table-column
        prop="amount"
        label="额度">
      </el-table-column>

    </el-table>

  </div>

</template>

<script>
  export default {
    name: 'cardlistTotal',
    data() {
      return {
        input: '',
        tableData: [],

      }
    },
    methods: {
      getDataMethod() {
        this.$fetch('/card/api/card/count')
          .then((response) => {
            console.log(response)
            this.tableData = response;
          })
          .catch(response => {
            console.log(response)
          })
      },

      getSummaries(param) {
        const { columns, data } = param;
        const sums = [];
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '总价';
            return;
          }
          const values = data.map(item => Number(item[column.property]));
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            sums[index] += ' 元';
          } else {
            sums[index] = 'N/A';
          }
        });

        return sums;
      }

    },
    watch: {},
    created() {
      this.getDataMethod();
    }
  }

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1, h2 {
    font-weight: normal;
  }

  ul {
    list-style-type: none;
    padding: 0;
  }

  li {
    display: inline-block;
    margin: 0 10px;
  }

  a {
    color: #42b983;
  }
</style>
